﻿// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

//using DotNetFramework.CAP.Transport;
//using Microsoft.Extensions.Options;

using DotNetFramework.CAP.Abstractions;
using DotNetFramework.CAP.Core.Logger;

namespace DotNetFramework.CAP.Mqtt
{
    public class MqttConsumerClientFactory : IConsumerClientFactory
    {
        private readonly MqttOptions _mqttOptions;
        IContentSerializer _serializer;
        ILogger _logger;

        public MqttConsumerClientFactory(ILogger logger, MqttOptions mqttOptions, IContentSerializer serializer)
        {
            _logger = logger;
            _mqttOptions = mqttOptions;
            _serializer = serializer;
        }

        public virtual IConsumerClient Create(string groupId)
        {
            try
            {
                return new MqttConsumerClient(_logger, groupId, _mqttOptions, _serializer);
            }
            catch (System.Exception e)
            {
                throw new BrokerConnectionException(e);
            }
        }
    }
}